package com.xing.tools;

import com.xing.vo.ForumUser;
import org.apache.http.HttpEntity;
import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpRequest;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;

import javax.net.ssl.SSLException;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by xingzhe on 2018/8/7.
 */
public class Even {
    private static int timeSpace = 32000;

    public static void main(String[] args) throws Exception {
        signBili();
        sign115();

        for (ForumUser forumUser : init()) {
            acceptSignInReply(forumUser);
            acceptNormalReply(forumUser);
            replyNormalAndSignIn(forumUser);
            finishNormalReply(forumUser);
            finishSignInReply(forumUser);

            acceptShowGirlReply(forumUser);
            replyShowGirl(forumUser);
            finishShowGirlReply(forumUser);
        }

        fuliTask();
        visit();
    }

    private static List<ForumUser> init(){
        List<ForumUser> forumUsers = new ArrayList<>();
        forumUsers.add(new ForumUser("t2xingzhe","6a67914b","UM_distinctid=164c53486da28d-064e372a60f1e3-163b6953-13c680-164c53486db74f; CNZZDATA1261995008=952548503-1532311539-%7C1534990290; aU84_4a9b_sid=ca15vQ; aU84_4a9b_saltkey=h2oqg2de; aU84_4a9b_lastvisit=1534989559; aU84_4a9b_ulastactivity=ef5a5Rlh6v6bGPszPtzThiJeMGLwgu5ZaJcm4d%2Bd2lxvTBPBhonK; aU84_4a9b_auth=fcc3uFNrpsHF%2FF5TjjeaHoHMTLsRi0mQ46O9LFf2ONE%2BRnV61NC9S4HgPhIGHtxKb0d7lQrCcnqb6TfT%2FR%2BOyxzN7ss; aU84_4a9b_lastcheckfeed=678487%7C1534993161; aU84_4a9b_lip=103.37.140.37%2C1534992735; aU84_4a9b_connect_is_bind=0; aU84_4a9b_visitedfid=65; aU84_4a9b_st_t=678487%7C1534993244%7C4db333d429d0d9f8fcfefeac95d0a9e4; aU84_4a9b_forum_lastvisit=D_65_1534993244; aU84_4a9b_viewid=uid_678487; aU84_4a9b_home_diymode=1; aU84_4a9b_sendmail=1; _d_id=06e889b1f0e736dbb148dfda93e608; aU84_4a9b_lastact=1534993513%09home.php%09spacecp"));
        forumUsers.add(new ForumUser("清爽阳光","6e85fc22","UM_distinctid=164c53486da28d-064e372a60f1e3-163b6953-13c680-164c53486db74f; CNZZDATA1261995008=952548503-1532311539-%7C1534990290; aU84_4a9b_sid=ca15vQ; aU84_4a9b_saltkey=Pi75ojA1; aU84_4a9b_lastvisit=1534990917; aU84_4a9b_sendmail=1; aU84_4a9b_ulastactivity=f6edys2T53JRMQLD7oqDWS9FXkDzkNJ9APGt503hwgxRdPtm7eVQ; aU84_4a9b_auth=a48aHLo9lhnRCKHdF3qM8S5pXwhsfsUUwR9ak5xqlQFifA7s0Aebw0iIcH6HgVY%2Bvv14yviJpipezZt%2BJn6%2BVowzUt4; aU84_4a9b_lastcheckfeed=746813%7C1534994521; aU84_4a9b_checkfollow=1; aU84_4a9b_lip=103.37.140.37%2C1534993105; aU84_4a9b_connect_is_bind=0; aU84_4a9b_nofavfid=1; aU84_4a9b_checkpm=1; aU84_4a9b_lastact=1534994527%09forum.php%09viewthread; aU84_4a9b_st_p=746813%7C1534994527%7Cd3f93e1fbff7256bfb33abe893fcc116; aU84_4a9b_visitedfid=65; aU84_4a9b_viewid=tid_9988; _d_id=980874b1f0e7364c08b9dfda638d96; aU84_4a9b_smile=1D1"));
        forumUsers.add(new ForumUser("飞舞的胖次","59689cbd","UM_distinctid=164c53486da28d-064e372a60f1e3-163b6953-13c680-164c53486db74f; CNZZDATA1261995008=952548503-1532311539-%7C1534990290; aU84_4a9b_sid=ca15vQ; aU84_4a9b_saltkey=vck21vBA; aU84_4a9b_lastvisit=1534991012; aU84_4a9b_sendmail=1; aU84_4a9b_ulastactivity=289cmSivg28INMFF2yY%2FLm7a3TbluvaeRjdit2sQH4HmH1NB%2BHp%2B; aU84_4a9b_auth=38e1LbUTwY8dp99zXE8FGqaveyCEW2QVU0RWfbmeqiibJ872fxr5HTxEAt3tqVglulFrACjzJT3rNv4vwA8TiwvUXBg; aU84_4a9b_lastcheckfeed=746909%7C1534994615; aU84_4a9b_checkfollow=1; aU84_4a9b_lip=103.37.140.37%2C1534992739; aU84_4a9b_connect_is_bind=0; aU84_4a9b_nofavfid=1; aU84_4a9b_checkpm=1; aU84_4a9b_lastact=1534994620%09forum.php%09viewthread; aU84_4a9b_st_p=746909%7C1534994620%7C6fa88fed46b8ce95d76b6b8a30c9021e; aU84_4a9b_visitedfid=65; aU84_4a9b_viewid=tid_66811; _d_id=6f8476b1f0e73618f756dfda638d61; aU84_4a9b_smile=1D1"));
        forumUsers.add(new ForumUser("flower蓉","6aa06927","UM_distinctid=164c53486da28d-064e372a60f1e3-163b6953-13c680-164c53486db74f; CNZZDATA1261995008=952548503-1532311539-%7C1535017293; aU84_4a9b_sid=c40b5l; aU84_4a9b_saltkey=kzhrakKI; aU84_4a9b_lastvisit=1535016148; aU84_4a9b_ulastactivity=476cHdY8q2HTYsTi%2B9GVxBQyew4K%2BWTXj6s%2FU9V0v%2Fo0yOzFemZ9; aU84_4a9b_auth=a75d4vE5Ajcdy0TakfIW8%2FuYp0Ym8HVziUgEAsV6nU6m%2B0sdktp53qSUU%2BoBBtM%2FH%2B8yuDuhXhGfZ2h1II%2FCSuVeMm8; aU84_4a9b_connect_is_bind=0; aU84_4a9b_nofavfid=1; aU84_4a9b_smile=1D1; aU84_4a9b_st_t=749094%7C1535019808%7C7c6067ce05f72c97711175ac8e58b1b2; aU84_4a9b_forum_lastvisit=D_76_1535019808; aU84_4a9b_forumdefstyle=1; aU84_4a9b_clearUserdata=forum; aU84_4a9b_connect_not_sync_t=1; aU84_4a9b_visitedfid=76D2; _d_id=544220b1f0e7362aebf7dfda343f5a; aU84_4a9b_lastact=1535020603%09forum.php%09viewthread; aU84_4a9b_st_p=749094%7C1535020603%7C29cb4b0488ceec2d3f038276098df120; aU84_4a9b_viewid=tid_135336"));
        forumUsers.add(new ForumUser("胡杨","2b23f197","UM_distinctid=164c53486da28d-064e372a60f1e3-163b6953-13c680-164c53486db74f; CNZZDATA1261995008=952548503-1532311539-%7C1535022692; aU84_4a9b_sid=X0IClz; aU84_4a9b_saltkey=e1oKdcWH; aU84_4a9b_lastvisit=1535020271; aU84_4a9b_ulastactivity=032fXIab2McUUeox8055Mi48bcrboEx2Qr4iPz7j0VW1NN1pX5e3; aU84_4a9b_auth=7e58Y5zjRRqkJqjwIaPoFeGU9OM47H8s%2B1mbGS91POCM7NNrXmYewqh83Ar9dLHvuLQGNDOzRvv6rcTwYGi14M6j%2Fog; aU84_4a9b_connect_is_bind=0; aU84_4a9b_nofavfid=1; aU84_4a9b_noticeTitle=1; aU84_4a9b_smile=1D1; aU84_4a9b_forumdefstyle=1; aU84_4a9b_connect_not_sync_t=1; aU84_4a9b_taskdoing_749188=1; _d_id=1ce885b1f0e7366460c9dfda93e612; aU84_4a9b_sendmail=1; aU84_4a9b_st_t=749188%7C1535024258%7Cb94313626e1120ea2c0f82a2b86fe449; aU84_4a9b_forum_lastvisit=D_76_1535024258; aU84_4a9b_visitedfid=65D76D2; aU84_4a9b_viewid=tid_135460; aU84_4a9b_clearUserdata=forum; aU84_4a9b_lastact=1535024290%09forum.php%09viewthread; aU84_4a9b_st_p=749188%7C1535024290%7Cca32efce04f9ffa55e0c52ca216de338"));
        return forumUsers;
    }

    private static void signBili() throws Exception {
        String url = "https://account.bilibili.com/site/getCoin";
        CloseableHttpClient httpClient = org.apache.http.impl.client.HttpClients.createDefault();
        RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(15000)
                .setConnectTimeout(15000)
                .build();
        HttpGet get = new HttpGet(url);
        get.setConfig(requestConfig);
        get.setHeader("Accept", "*/*");
        get.setHeader("Cookie", "fts=1519024212; sid=hv5fnr8e; UM_distinctid=161ace730dd146-0077a1ac2fb957-32677402-13c680-161ace730de7cc; buvid3=21E10684-56FF-4D5A-82F9-1F960336C8DC31211infoc; rpdid=oqmpliilxwdosolwipkiw; im_notify_type_12134821=0; finger=14bc3c4e; DedeUserID=12134821; DedeUserID__ckMd5=f252f4fb9d24b1f4; SESSDATA=809339eb%2C1535242441%2Cedd8530a; bili_jct=9d221df590dd0a423c1cc4f3d3330e7a; LIVE_BUVID=b66a7d3640c9d15cebbc4133240eb0c1; LIVE_BUVID__ckMd5=4e13aabd04df0886; BANGUMI_SS_24596_REC=232535; CURRENT_QUALITY=64; bp_t_offset_12134821=149524132450469509; _dfcaptcha=51cbfb671c24dbd893967384b1260c79");
        get.setHeader("Referer", "https://www.bilibili.com/");
        get.setHeader("Host", "account.bilibili.com");
        get.setHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36");
        CloseableHttpResponse response = httpClient.execute(get);
        if (response.getStatusLine().getStatusCode() == 200) {
            HttpEntity entity = response.getEntity();
            String content = EntityUtils.toString(entity, "utf-8");
            if (content.contains("money")) {
                System.out.println(content);
            } else {
                System.out.println("Error! " + content);
            }
        } else {
            System.out.println("status_line:" + response.getStatusLine().getStatusCode());
        }
    }

    private static void fuliTask() throws Exception {
        String url = "http://www.wnflb.com/plugin.php?id=fx_checkin:checkin&formhash=d865477a&d865477a&infloat=yes&handlekey=fx_checkin&inajax=1&ajaxtarget=fwin_content_fx_checkin";
        CloseableHttpClient httpClient = org.apache.http.impl.client.HttpClients.createDefault();
        RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(15000)
                .setConnectTimeout(15000)
                .build();
        HttpGet get = new HttpGet(url);
        get.setConfig(requestConfig);
        get.setHeader("Accept", "*/*");
        get.setHeader("Cookie", "pz4N_2132_saltkey=d4xtOgLo; pz4N_2132_lastvisit=1531409114; pz4N_2132_atarget=1; pz4N_2132_blueidea_login=1; pz4N_2132_nofavfid=1; pz4N_2132_smile=1D1; pz4N_2132_visitedfid=2D42D37D44; pz4N_2132_auth=fe44nhEbZqtbz2THgaKvH8LaY0HDcujyPWtpd6G5WHyVMhH7YhQGY9SKTRFWb8IeRZ5Q7weAfIzxTXU5gkiaeBYtFg; pz4N_2132_lastcheckfeed=70337%7C1531796840; pz4N_2132_home_diymode=1; pz4N_2132_forum_lastvisit=D_2_1533215133; pz4N_2132_st_t=70337%7C1533215572%7C1ca717afd38c82e56582391ddf9513c2; pz4N_2132_st_p=70337%7C1533269157%7Cce7eb947ddba503c3b77e9cfeb15fc0a; pz4N_2132_viewid=tid_118656; pz4N_2132_sid=l3s11C; pz4N_2132_lip=103.37.140.5%2C1533536485; pz4N_2132_pc_size_c=0; pz4N_2132_ulastactivity=278039Jh0eCQePTcOdPlQAy4zz593m%2B0fvVz9G0rfON87MWE1bGc; pz4N_2132_sendmail=1; pz4N_2132_lastact=1533702510%09home.php%09spacecp");
        get.setHeader("Referer", "http://www.wnflb.com/");
        get.setHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36");
        CloseableHttpResponse response = httpClient.execute(get);
        if (response.getStatusLine().getStatusCode() == 200) {
            HttpEntity entity = response.getEntity();
            String content = EntityUtils.toString(entity, "gbk");
            if (content.contains("签到成功")) {
                System.out.println("done");
            } else {
                System.out.println("Error! " + content);
            }
        } else {
            System.out.println("status_line:" + response.getStatusLine().getStatusCode());
        }
    }

    private static void visit() throws Exception {
        for (int i = 1; i < 100; i++) {
            String url = "http://www.9damao.com/forum-40-" + i + ".html";
            HttpRequestRetryHandler myRetryHandler = getRetry();
            CloseableHttpClient httpClient = org.apache.http.impl.client.HttpClients.custom()
                    .setRetryHandler(myRetryHandler)
                    .build();
            RequestConfig requestConfig = RequestConfig.custom()
                    .setSocketTimeout(15000)
                    .setConnectTimeout(15000)
                    .build();
            HttpGet get = new HttpGet(url);
            get.setConfig(requestConfig);
            get.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
            get.setHeader("Accept-Encoding", "gzip, deflate");
            get.setHeader("Cookie", "aU84_4a9b_saltkey=vB11eIlL; aU84_4a9b_lastvisit=1532313306; UM_distinctid=164c53486da28d-064e372a60f1e3-163b6953-13c680-164c53486db74f; aU84_4a9b_connect_is_bind=0; aU84_4a9b_nofavfid=1; aU84_4a9b_auth=c34d1QC4i9aAATBdRQtxp7FCz4hPT5evyPNF8x81V1UVlGPD%2FNvhPdUe7Zh%2FXsiyC%2F%2FO3jZvN4xuw7%2BQ0vPlTb68BXI; aU84_4a9b_lastcheckfeed=678487%7C1532769922; aU84_4a9b_connect_not_sync_t=1; aU84_4a9b_forumdefstyle=1; aU84_4a9b_smile=3D2; aU84_4a9b_home_diymode=1; aU84_4a9b_visitedfid=40D64D2D294D37D65D76; aU84_4a9b_st_p=678487%7C1533562384%7Cb54abbe3e3a3ac1d761d6e4151c6737f; aU84_4a9b_viewid=tid_125294; aU84_4a9b_sid=Q21L84; aU84_4a9b_lip=101.240.118.5%2C1533568953; aU84_4a9b_st_t=678487%7C1533607594%7Cc2890fbd3233b2b3156a0169949353c7; aU84_4a9b_forum_lastvisit=D_40_1533607594; aU84_4a9b_ulastactivity=bac7sBU%2FogfVN3s%2BS2ZvMN%2BXx00kt%2B6q%2FcKK2v4ipFVjuOKO3%2BdT; CNZZDATA1261995008=952548503-1532311539-%7C1533602284; aU84_4a9b_noticeTitle=1; _d_id=78e700223154a0295e8b4c1b93e676; aU84_4a9b_lastact=1533607617%09home.php%09task");
            get.setHeader("Host", "www.9damao.com");
            get.setHeader("Referer", "http://www.9damao.com/home.php?mod=task");
            get.setHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36");
            CloseableHttpResponse response = httpClient.execute(get);
            if (response.getStatusLine().getStatusCode() == 200) {
                System.out.println("done! list: " + i);
            } else {
                System.out.println("error");
            }
            Thread.sleep(300000);
        }
    }

    private static void replyNormalAndSignIn(ForumUser forumUser) throws Exception {
        String url = "http://www.9damao.com/forum.php?mod=post&action=reply&fid=2&tid=135096&extra=page%3D1&replysubmit=yes&infloat=yes&handlekey=fastpost&inajax=1";
        CloseableHttpClient httpClient = org.apache.http.impl.client.HttpClients.createDefault();
        RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(15000)
                .setConnectTimeout(15000)
                .build();
        HttpPost get = new HttpPost(url);
        get.setConfig(requestConfig);
        get.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
        get.setHeader("Accept-Encoding", "gzip, deflate");
        get.setHeader("Cookie", forumUser.getCook());
        get.setHeader("Host", "www.9damao.com");
        get.setHeader("Referer", "http://www.9damao.com/home.php?mod=task");
        get.setHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36");
        // 构建提交参数
        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        nvps.add(new BasicNameValuePair("message", "祝越办越好~希望能被选中，每日签到"));
        nvps.add(new BasicNameValuePair("posttime", (System.currentTimeMillis() / 1000) + ""));
        nvps.add(new BasicNameValuePair("formhash", forumUser.getForumHash()));
        nvps.add(new BasicNameValuePair("usesig", "1"));
        get.setEntity(new UrlEncodedFormEntity(nvps, "gbk"));
        CloseableHttpResponse response = httpClient.execute(get);
        if (response.getStatusLine().getStatusCode() == 200) {
            HttpEntity entity = response.getEntity();
            String content = EntityUtils.toString(entity, "gbk");
            if (content.contains("非常感谢，回复发布成功")) {
                System.out.println("done");
            } else {
                System.out.println("Error! " + content);
            }
        } else {
            System.out.println("status_line:" + response.getStatusLine().getStatusCode());
        }
        Thread.sleep(timeSpace);
    }

    private static void replyShowGirl(ForumUser forumUser) throws Exception {
        String url = "http://www.9damao.com/forum.php?mod=post&action=reply&fid=76&tid=134464&extra=page%3D1&replysubmit=yes&infloat=yes&handlekey=fastpost&inajax=1";
        CloseableHttpClient httpClient = org.apache.http.impl.client.HttpClients.createDefault();
        RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(15000)
                .setConnectTimeout(15000)
                .build();
        HttpPost get = new HttpPost(url);
        get.setConfig(requestConfig);
        get.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
        get.setHeader("Accept-Encoding", "gzip, deflate");
        get.setHeader("Cookie", forumUser.getCook());
        get.setHeader("Host", "www.9damao.com");
        get.setHeader("Referer", "http://www.9damao.com/home.php?mod=task");
        get.setHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36");
        // 构建提交参数
        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        nvps.add(new BasicNameValuePair("message", "支持支持，每日签到"));
        nvps.add(new BasicNameValuePair("posttime", (System.currentTimeMillis() / 1000) + ""));
        nvps.add(new BasicNameValuePair("formhash", forumUser.getForumHash()));
        nvps.add(new BasicNameValuePair("usesig", "1"));
        get.setEntity(new UrlEncodedFormEntity(nvps, "gbk"));
        CloseableHttpResponse response = httpClient.execute(get);
        if (response.getStatusLine().getStatusCode() == 200) {
            HttpEntity entity = response.getEntity();
            String content = EntityUtils.toString(entity, "gbk");
            if (content.contains("非常感谢，回复发布成功")) {
                System.out.println("done");
            } else {
                System.out.println("Error! " + content);
            }
        } else {
            System.out.println("status_line:" + response.getStatusLine().getStatusCode());
        }
        Thread.sleep(timeSpace);
    }

    private static void sign115() throws Exception {
        String url = "http://webapi.115.com/user/sign";
        CloseableHttpClient httpClient = org.apache.http.impl.client.HttpClients.createDefault();
        RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(15000)
                .setConnectTimeout(15000)
                .build();
        HttpPost get = new HttpPost(url);
        get.setConfig(requestConfig);
        get.setHeader("Accept", "*/*");
        get.setHeader("Origin", "http://webapi.115.com");
        get.setHeader("Cookie", "115_lang=system; CID=02ea41cbdd1fc4e6c669e6cdf453e19d; SEID=9ac3ae5233dea6033e345b8b3b43ad22f8d42a51bd336ad4f157b17a565938f871cf4830996f911a38ae4e7c3d1f9e2e18de7102f33373fe843762c3; UID=2955186_D1_1528470230");
        get.setHeader("Host", "webapi.115.com");
        get.setHeader("X-Requested-With", "XMLHttpRequest");
        get.setHeader("Accept-Encoding", "gzip, deflate");
        get.setHeader("Referer", "http://webapi.115.com/bridge_2.0.html?namespace=FS.DataSrv&api=UDataAPI&_t=v5");
        get.setHeader("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 10_2_1 like Mac OS X) AppleWebKit/602.4.6 (KHTML, like Gecko) Mobile/14D27 UDown/8.0.2");
        CloseableHttpResponse response = httpClient.execute(get);
        if (response.getStatusLine().getStatusCode() == 200) {
            HttpEntity entity = response.getEntity();
            String content = EntityUtils.toString(entity, "gbk");
            if (content.contains("true")) {
                System.out.println("done");
            } else {
                System.out.println("Error! " + content);
            }
        } else {
            System.out.println("status_line:" + response.getStatusLine().getStatusCode());
        }
    }

    private static void finishNormalReply(ForumUser forumUser) throws Exception {
        String url = "http://www.9damao.com/home.php?mod=task&do=draw&id=4";
        CloseableHttpClient httpClient = org.apache.http.impl.client.HttpClients.createDefault();
        RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(15000)
                .setConnectTimeout(15000)
                .build();
        HttpGet get = new HttpGet(url);
        get.setConfig(requestConfig);
        get.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
        get.setHeader("Accept-Encoding", "gzip, deflate");
        get.setHeader("Cookie", forumUser.getCook());
        get.setHeader("Host", "www.9damao.com");
        get.setHeader("Referer", "http://www.9damao.com/home.php?mod=task");
        get.setHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36");
        CloseableHttpResponse response = httpClient.execute(get);
        if (response.getStatusLine().getStatusCode() == 200) {
            HttpEntity entity = response.getEntity();
            String content = EntityUtils.toString(entity, "gbk");
            if (content.contains("恭喜您，任务已成功完成")) {
                System.out.println("done");
            } else {
                System.out.println("Error! " + content);
            }
        } else {
            System.out.println("status_line:" + response.getStatusLine().getStatusCode());
        }
        Thread.sleep(timeSpace);
    }

    private static void finishShowGirlReply(ForumUser forumUser) throws Exception {
        String url = "http://www.9damao.com/home.php?mod=task&do=draw&id=13";
        CloseableHttpClient httpClient = org.apache.http.impl.client.HttpClients.createDefault();
        RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(15000)
                .setConnectTimeout(15000)
                .build();
        HttpGet get = new HttpGet(url);
        get.setConfig(requestConfig);
        get.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
        get.setHeader("Accept-Encoding", "gzip, deflate");
        get.setHeader("Cookie", forumUser.getCook());
        get.setHeader("Host", "www.9damao.com");
        get.setHeader("Referer", "http://www.9damao.com/home.php?mod=task");
        get.setHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36");
        CloseableHttpResponse response = httpClient.execute(get);
        if (response.getStatusLine().getStatusCode() == 200) {
            HttpEntity entity = response.getEntity();
            String content = EntityUtils.toString(entity, "gbk");
            if (content.contains("恭喜您，任务已成功完成")) {
                System.out.println("done");
            } else {
                System.out.println("Error! " + content);
            }
        } else {
            System.out.println("status_line:" + response.getStatusLine().getStatusCode());
        }
        Thread.sleep(timeSpace);
    }

    private static void finishSignInReply(ForumUser forumUser) throws Exception {
        String url = "http://www.9damao.com/home.php?mod=task&do=draw&id=7";
        CloseableHttpClient httpClient = org.apache.http.impl.client.HttpClients.createDefault();
        RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(15000)
                .setConnectTimeout(15000)
                .build();
        HttpGet get = new HttpGet(url);
        get.setConfig(requestConfig);
        get.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
        get.setHeader("Accept-Encoding", "gzip, deflate");
        get.setHeader("Cookie", forumUser.getCook());
        get.setHeader("Host", "www.9damao.com");
        get.setHeader("Referer", "http://www.9damao.com/home.php?mod=task");
        get.setHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36");
        CloseableHttpResponse response = httpClient.execute(get);
        if (response.getStatusLine().getStatusCode() == 200) {
            HttpEntity entity = response.getEntity();
            String content = EntityUtils.toString(entity, "gbk");
            if (content.contains("恭喜您，任务已成功完成")) {
                System.out.println("done");
            } else {
                System.out.println("Error! " + content);
            }
        } else {
            System.out.println("status_line:" + response.getStatusLine().getStatusCode());
        }
        Thread.sleep(timeSpace);
    }

    private static void acceptNormalReply(ForumUser forumUser) throws Exception {
        String url = "http://www.9damao.com/home.php?mod=task&do=apply&id=4";
        CloseableHttpClient httpClient = org.apache.http.impl.client.HttpClients.createDefault();
        RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(15000)
                .setConnectTimeout(15000)
                .build();
        HttpGet get = new HttpGet(url);
        get.setConfig(requestConfig);
        get.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
        get.setHeader("Accept-Encoding", "gzip, deflate");
        get.setHeader("Cookie", forumUser.getCook());
        get.setHeader("Host", "www.9damao.com");
        get.setHeader("Referer", "http://www.9damao.com/home.php?mod=task");
        get.setHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36");
        CloseableHttpResponse response = httpClient.execute(get);
        if (response.getStatusLine().getStatusCode() == 200) {
            HttpEntity entity = response.getEntity();
            String content = EntityUtils.toString(entity, "gbk");
            if (content.contains("任务申请成功")) {
                System.out.println("done");
            } else {
                System.out.println("Error! " + content);
            }
        } else {
            System.out.println("status_line:" + response.getStatusLine().getStatusCode());
        }
        Thread.sleep(timeSpace);
    }

    private static void acceptShowGirlReply(ForumUser forumUser) throws Exception {
        String url = "http://www.9damao.com/home.php?mod=task&do=apply&id=13";
        CloseableHttpClient httpClient = org.apache.http.impl.client.HttpClients.createDefault();
        RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(15000)
                .setConnectTimeout(15000)
                .build();
        HttpGet get = new HttpGet(url);
        get.setConfig(requestConfig);
        get.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
        get.setHeader("Accept-Encoding", "gzip, deflate");
        get.setHeader("Cookie", forumUser.getCook());
        get.setHeader("Host", "www.9damao.com");
        get.setHeader("Referer", "http://www.9damao.com/home.php?mod=task");
        get.setHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36");
        CloseableHttpResponse response = httpClient.execute(get);
        if (response.getStatusLine().getStatusCode() == 200) {
            HttpEntity entity = response.getEntity();
            String content = EntityUtils.toString(entity, "gbk");
            if (content.contains("任务申请成功")) {
                System.out.println("done");
            } else {
                System.out.println("Error! " + content);
            }
        } else {
            System.out.println("status_line:" + response.getStatusLine().getStatusCode());
        }
        Thread.sleep(timeSpace);
    }

    private static void acceptSignInReply(ForumUser forumUser) throws Exception {
        String url = "http://www.9damao.com/home.php?mod=task&do=apply&id=7";
        CloseableHttpClient httpClient = org.apache.http.impl.client.HttpClients.createDefault();
        RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(15000)
                .setConnectTimeout(15000)
                .build();
        HttpGet get = new HttpGet(url);
        get.setConfig(requestConfig);
        get.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
        get.setHeader("Accept-Encoding", "gzip, deflate");
        get.setHeader("Cookie", forumUser.getCook());
        get.setHeader("Host", "www.9damao.com");
        get.setHeader("Referer", "http://www.9damao.com/home.php?mod=task");
        get.setHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36");
        CloseableHttpResponse response = httpClient.execute(get);
        if (response.getStatusLine().getStatusCode() == 200) {
            HttpEntity entity = response.getEntity();
            String content = EntityUtils.toString(entity, "gbk");
            if (content.contains("任务申请成功")) {
                System.out.println("done");
            } else {
                System.out.println("Error! " + content);
            }
        } else {
            System.out.println("status_line:" + response.getStatusLine().getStatusCode());
        }
        Thread.sleep(timeSpace);
    }

    public static HttpRequestRetryHandler getRetry() {
        HttpRequestRetryHandler myRetryHandler = new HttpRequestRetryHandler() {
            public boolean retryRequest(
                    IOException exception,
                    int executionCount,
                    HttpContext context) {
                if (executionCount >= 5) {
                    // Do not retry if over max retry count
                    return false;
                }
                if (exception instanceof InterruptedIOException) {
                    // Timeout
                    return false;
                }
                if (exception instanceof UnknownHostException) {
                    // Unknown host
                    return false;
                }
                if (exception instanceof org.apache.http.conn.ConnectTimeoutException) {
                    // Connection refused
                    return false;
                }
                if (exception instanceof SSLException) {
                    // SSL handshake exception
                    return false;
                }
                HttpClientContext clientContext = HttpClientContext.adapt(context);
                HttpRequest request = clientContext.getRequest();
                boolean idempotent = !(request instanceof HttpEntityEnclosingRequest);
                if (idempotent) {
                    // Retry if the request is considered idempotent
                    return true;
                }
                return false;
            }
        };
        return myRetryHandler;
    }
}
